import Vue from 'vue'
import App from './App'
import './common/tools';
import Store from './store/index';
import {Ajax} from '@u/ajax/index';
import './router'
// 全局组件
import FooterBar from '@c/tl-ui/FooterBar/index.vue'
import navBar from '@c/tl-ui/navBar/index.vue'
import Button from '@c/tl-ui/button/index.vue'
// #ifdef H5
import cax from '@c/tl-ui/cax/index.vue'
// #endif
// #ifdef H5
Vue.component('cax', cax);
// #endif
Vue.component('navBar', navBar);
Vue.component('footerBar', FooterBar);
Vue.component('tl-button', Button);
Promise.prototype.finally = function (callback) {
    let P = this.constructor;
    return this.then(
        value => P.resolve(callback(value)).then(() => value),
        reason => P.resolve(callback(reason)).then(() => {
            throw reason
        })
    )
}


const config = require('./common/config/index');
//#ifdef H5
Vue.prototype.$jQuery = window.jQuery;
//#endif

// 全局配置
Vue.$config = config;
Vue.prototype.$config = config;

// 插件Plugin
Vue.$store = Store;
Vue.prototype.$store = Store;
const TAB_LINK = Store.state.User.tabBar.map(v => v.path);
Vue.TAB_LINK = TAB_LINK;
Vue.prototype.TAB_LINK = TAB_LINK;

const $ajax = new Ajax({...config, basicUrl: config.host}, Store);

Vue.$ajax = $ajax;
Vue.prototype.$ajax = $ajax;

Vue.config.productionTip = false;

App.mpType = 'app';

const app = new Vue({
    store: Store,
    ...App
});
app.$mount();
